package com.google.android.gms.internal;

import java.io.IOException;

public final class zzjm extends zzflm<zzjm> {
    private int[] zzbeu = zzflv.zzpvy;
    private Integer zzbew = null;

    public zzjm() {
        this.zzpvl = null;
        this.zzpnr = -1;
    }

    /* access modifiers changed from: private */
    /* renamed from: zzo */
    public final zzjm zza(zzflj zzflj) throws IOException {
        while (true) {
            int zzcxx = zzflj.zzcxx();
            if (zzcxx == 0) {
                return this;
            }
            if (zzcxx == 8) {
                int position = zzflj.getPosition();
                try {
                    this.zzbew = Integer.valueOf(zzjc.zzd(zzflj.zzcym()));
                } catch (IllegalArgumentException unused) {
                    zzflj.zzmw(position);
                    zza(zzflj, zzcxx);
                }
            } else if (zzcxx == 16) {
                int zzb = zzflv.zzb(zzflj, 16);
                int length = this.zzbeu == null ? 0 : this.zzbeu.length;
                int[] iArr = new int[(zzb + length)];
                if (length != 0) {
                    System.arraycopy(this.zzbeu, 0, iArr, 0, length);
                }
                while (length < iArr.length - 1) {
                    iArr[length] = zzflj.zzcym();
                    zzflj.zzcxx();
                    length++;
                }
                iArr[length] = zzflj.zzcym();
                this.zzbeu = iArr;
            } else if (zzcxx == 18) {
                int zzli = zzflj.zzli(zzflj.zzcym());
                int position2 = zzflj.getPosition();
                int i = 0;
                while (zzflj.zzcyo() > 0) {
                    zzflj.zzcym();
                    i++;
                }
                zzflj.zzmw(position2);
                int length2 = this.zzbeu == null ? 0 : this.zzbeu.length;
                int[] iArr2 = new int[(i + length2)];
                if (length2 != 0) {
                    System.arraycopy(this.zzbeu, 0, iArr2, 0, length2);
                }
                while (length2 < iArr2.length) {
                    iArr2[length2] = zzflj.zzcym();
                    length2++;
                }
                this.zzbeu = iArr2;
                zzflj.zzlj(zzli);
            } else if (!super.zza(zzflj, zzcxx)) {
                return this;
            }
        }
    }

    public final void zza(zzflk zzflk) throws IOException {
        if (this.zzbew != null) {
            zzflk.zzad(1, this.zzbew.intValue());
        }
        if (this.zzbeu != null && this.zzbeu.length > 0) {
            for (int zzad : this.zzbeu) {
                zzflk.zzad(2, zzad);
            }
        }
        super.zza(zzflk);
    }

    /* access modifiers changed from: protected */
    public final int zzq() {
        int zzq = super.zzq();
        if (this.zzbew != null) {
            zzq += zzflk.zzag(1, this.zzbew.intValue());
        }
        if (this.zzbeu == null || this.zzbeu.length <= 0) {
            return zzq;
        }
        int i = 0;
        for (int zzlx : this.zzbeu) {
            i += zzflk.zzlx(zzlx);
        }
        return zzq + i + (1 * this.zzbeu.length);
    }
}
